//Accepted
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int k, n, i, r=0, x;
char s[100002];
int  a[30];
bool p[30];//chars not elimined

vector< pair<int, int> > aa;

void read(){
	scanf("%s%d",s,&k);
	for(i=0;i<30;i++)aa.push_back(make_pair(0,i));
}
void process(){
	n=strlen(s);
	if(k>=n){
		printf("0\n");
		return;
	}
	for(i=0;i<n;i++)aa[s[i]-'a'].first++;
	sort(aa.begin() , aa.end() );
	
	for(i=0;i<30;i++)if(aa[i].first)r++;//numero de letras
	
	x=k;
	for(i=0;i<30;i++)
		if(aa[i].first){
			if(aa[i].first<=x){
				x-=aa[i].first;
				r--;
				p[aa[i].second]=1;//don't print this char
			}
			else break;
		}
	
	printf("%d\n",r);
	for(i=0;i<n;i++)if(!p[ s[i]-'a' ])printf("%c",s[i]);
	
	
}
int main(){
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	read();
	process();
	return 0;
}
